<div id="maincontent">
  <div id="content">
    <div class="box1">
      <h3><?php echo lico_lang('profile', 'personal.certificate'); ?></h3>
        <?php
        $desc = lico_lang('profile', 'personal.certificate.description');
        $desc = str_replace("#certurl#", "<a href=\"".$lico['baseurl.ssl']."/cert/".intval($_SESSION['userid']).".png\">".$lico['baseurl.ssl']."/cert/".intval($_SESSION['userid']).".png</a>", $desc);
        $desc = str_replace("#publicurl#", "<a href=\"".$lico['baseurl.ssl']."/user/".intval($_SESSION['userid']).".html\">".$lico['baseurl.ssl']."/user/".intval($_SESSION['userid']).".html</a>", $desc);
        ?>
        <div id="personal-certificate">
          
          <div id="certificate">
            <label class="certificate-label"><?php echo $desc; ?></label>
            <span class="certificate-value"><a href="<?php echo $lico['baseurl.ssl']; ?>/user/<?php echo intval($_SESSION['userid']); ?>.html"><img src="/cert/<?php echo intval($_SESSION['userid']); ?>.png" alt="Certificate for <?php echo intval($_SESSION['userid']); ?>" title="Certificate for <?php echo intval($_SESSION['userid']); ?>"/></a></span>
          </div>
          
          
        </div>
        
    </div>
    <div class="box2">
      <h3><?php echo lico_lang('profile', 'personal.information'); ?></h3>
        <div class="description"><?php echo lico_lang('profile', 'personal.information.description'); ?></div>
        <?php
        $select = "SELECT *, UNIX_TIMESTAMP(f_ctime), UNIX_TIMESTAMP(f_mtime) FROM `users` WHERE `f_key`='".lico_ESC($_SESSION['userid'])."'";
        $seluser = $db->unbuffered_query_first($select);
        if (isset($seluser[0]) && intval($seluser[0]) >= 1) {
           //  f_key 	f_raw 	f_clean 	f_ctime 	f_mtime 	email 	login 	state 	privacy 	credentials 	logintime 	emailtime 	lang
           $mycounternum = intval($seluser[0]);
           $myregtime = lico_getdatetime(intval($seluser[16]));
           $mylastchangetime = lico_getdatetime(intval($seluser[17]));
           $myemail = trim($seluser[5]);
           $myoldcounternum = trim($seluser[13]);
           $publishemail = trim($seluser[8]);
           $openid = trim($seluser[14]);
           $username = trim($seluser[15]);
        }
        $select = "SELECT *, UNIX_TIMESTAMP(f_ctime), UNIX_TIMESTAMP(f_mtime) FROM `persons` WHERE `f_key`='".lico_ESC($_SESSION['userid'])."'";
        $seluser = $db->unbuffered_query_first($select);
        if (isset($seluser[0]) && intval($seluser[0]) >= 1) {
          //  f_key 	f_raw 	f_clean 	f_ctime 	f_mtime 	name 	placeid 	placesource 	city 	state 	country 	email 	homepage 	ident 	may_publish 	method 	started 	usage
          $myname = trim($seluser[5]);
          $placeid = trim($seluser[6]);
          $placesource = trim($seluser[7]);
          $mycity = trim($seluser[8]);
          $mystate = trim($seluser[9]);
          $mycountry = trim($seluser[10]);
          $myhomepage = trim($seluser[12]);
          $publishinfo = trim($seluser[14]);
          $started = trim($seluser[16]);
          $usages = trim($seluser[17]);
          if (trim($started) != "") {
            $tmp = explode(" ", $started);
            $started_month = $tmp[0];
            $started_year = $tmp[1];
          }
          $usage = array();
          if (trim($usages) != "" && preg_match("`, `", $usages)) {
            $usage = explode(", ", $usages);
          } else {
            $usage[] = trim($usages);
          }
        }
        ?>
        <div id="personal-information">
          
          <div id="mynumber" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'mynumber'); ?></label>
            <span class="infotable-value"><?php echo $mycounternum; ?></span>
          </div>
          
          <div id="myusername" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'myusername'); ?></label>
            <span class="infotable-value"><?php echo $username; ?></span>
          </div>
          
          <!-- div id="myopenid" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'openid'); ?></label>
            <span class="infotable-value"><?php echo $openid; ?></span>
          </div -->
          
          <div id="myregtime" class="infotable-line even">
            <label class="infotable-label"><?php echo lico_lang('profile', 'registration.created'); ?></label>
            <span class="infotable-value"><?php echo $myregtime; ?></span>
          </div>
          
          <div id="mylastchangetime" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'last.change'); ?></label>
            <span class="infotable-value"><?php echo $mylastchangetime; ?></span>
          </div>
          
          <div id="myname" class="infotable-line even">
            <label class="infotable-label"><?php echo lico_lang('profile', 'myname'); ?></label>
            <span class="infotable-value"><?php echo $myname; ?></span>
          </div>
          
          <div id="myemail" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'myemail'); ?></label>
            <span class="infotable-value"><?php echo $myemail; ?></span>
          </div>
          
          <div id="myhomepage" class="infotable-line even">
            <label class="infotable-label"><?php echo lico_lang('profile', 'myhomepage'); ?></label>
            <span class="infotable-value"><?php echo $myhomepage; ?></span>
          </div>
          
          <div id="mycountry" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'mycountry'); ?></label>
            <span class="infotable-value"><?php echo $mycountry; ?></span>
          </div>
          
          <div id="mystate" class="infotable-line even">
            <label class="infotable-label"><?php echo lico_lang('profile', 'mystate'); ?></label>
            <span class="infotable-value"><?php echo $mystate; ?></span>
          </div>
          
          <div id="mycity" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'mycity'); ?></label>
            <span class="infotable-value"><?php echo $mycity; ?></span>
          </div>
          
          <div id="mystate" class="infotable-line even">
            <label class="infotable-label"><?php echo lico_lang('profile', 'started'); ?></label>
            <span class="infotable-value"><?php echo $started; ?></span>
          </div>
          
          <div id="mycity" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'usage'); ?></label>
            <span class="infotable-value"><?php 
            $myusage = "";
            for ($i=0; $i<count($lico['usages']); $i++) {
              $thisusage = $lico['usages'][$i];
              if (in_array($thisusage, $usage)) {
                if ($myusage!="") $myusage .= ", ";
                $myusage .= lico_lang('profile', 'usage.'.$lico['usages'][$i]);
              }
            }
            echo $myusage;
            ?></span>
          </div>
          
          <div id="mycity" class="infotable-line even">
            <label class="infotable-label"><?php echo lico_lang('profile', 'may.publish.email'); ?></label>
            <span class="infotable-value"><?php echo $publishemail; ?></span>
          </div>
          
          <div id="mycity" class="infotable-line odd">
            <label class="infotable-label"><?php echo lico_lang('profile', 'may.publish.info'); ?></label>
            <span class="infotable-value"><?php echo $publishinfo; ?></span>
          </div>
          
        </div>
        
    </div><a name="openid"></a>
    <div class="box3">
      <h3><?php echo lico_lang('profile', 'openid.information'); ?></h3>
      <div class="description"><?php echo lico_lang('profile', 'openid.information.description'); ?></div>
      <div id="openid-information">
        <?php
        $select = "SELECT * FROM `openid` WHERE `owner`='".lico_ESC($_SESSION['userid'])."'";
    		$ret = $db->getAll_assoc($select);
    		$class = "odd";
    		if (count($ret) <= 0) {
          echo "<span style=\"display: block; font-weight: bold; text-align: center;\">".lico_lang('profile', 'no.openids.registered')."</span>\n";
        } else {
  				for ($a=0; $a<count($ret); $a++) {
  				  if ($class == "odd") { $class = "even"; } else { $class = "odd"; }
  					$id = intval($ret[$a]['id']);
  					$url = trim($ret[$a]['url']);
            $service = trim($ret[$a]['service']);
            ?>
            <div class="infotable-line <?php echo $class; ?> <?php echo ($isactive=="NO"?"notactive":"active"); ?>">
              <ul class="infotable-ul">
                <li class="infotable-li col16p"><img style="width:70px;" src="/gfx/<?php echo $service; ?>B.png" border="0"/></li>
                <li class="infotable-li col81p"><?php echo htmlspecialchars($url); ?></li>
                <li class="infotable-li delete"><img src="/gfx/delete.png" title="Remove this OpenID account" alt="Remove this OpenID account" style="cursor:pointer;" onclick="RemoveOpenID(<?php echo $id; ?>);"/>&nbsp;</li>
              </ul>
            </div>
            <?php
          }
        }
        ?>
      </div>
      <div id="openid-box">
        <div id="openid-description">
          <?php echo lico_lang('profile', 'assign.openid.accounts'); ?>
        </div>
        
        <div id="google">
          <a href="/login/google.html">
            <img src="/gfx/googleB.png" border="0" alt="Login with your Google OpenID" title="Login with your Google OpenID"/>
          </a>
        </div>
        
        <div id="myopenid">
          <a href="/openid/MyOpenID.html">
            <img src="/gfx/myopenidB.png" border="0" alt="Login with your MyOpenID" title="Login with your MyOpenID"/>
          </a>
        </div>
        
        <div id="openid">
          <a href="/openid/OpenID.html">
            <img src="/gfx/openidB.png" border="0" alt="Login with your OpenID" title="Login with your OpenID"/>
          </a>
        </div>
      </div>
    </div>
    <div class="box4">
      <h3><?php echo lico_lang('profile', 'machines.information'); ?></h3>
        <div class="description"><?php echo lico_lang('profile', 'machines.information.description'); ?></div>
        <div id="machines-information">
        <?php
        $select = "SELECT *, UNIX_TIMESTAMP(f_ctime) AS ctime, UNIX_TIMESTAMP(f_mtime) AS mtime FROM `machines` WHERE `owner`='".lico_ESC($_SESSION['userid'])."'";
				$ret = $db->getAll_assoc($select);
				$class = "odd";
				if (count($ret) <= 0) {
          echo "<span style=\"float: left; font-weight: bold; text-align: center;\">".lico_lang('profile', 'no.machines.registered')."</span>\n";
        } else {
  				for ($a=0; $a<count($ret); $a++) {
  				  if ($class == "odd") { $class = "even"; } else { $class = "odd"; }
  					$id = intval($ret[$a]['f_key']);
  					$isactive = trim($ret[$a]['isactive']);
            $ctime = lico_getdatetime(intval($ret[$a]['ctime']));
            if (intval($ret[$a]['mtime']) >= 1)
              $mtime = lico_getdatetime(intval($ret[$a]['mtime']));
            else
              $mtime = $ctime;
            $name = trim($ret[$a]['name']);
            $select = "SELECT * FROM `processors` WHERE `f_key`='".lico_ESC($ret[$a]['cpu'])."'";
            $selcpu = $db->unbuffered_query_first($select);
            $cpu = trim($selcpu[1]);
            if (trim($selcpu[2]) != "")
              $cpu .= " @ ".trim($selcpu[2]);
            $sysclass = trim($ret[$a]['sysclass']);
            ?>
            <div class="infotable-line <?php echo $class; ?> <?php echo ($isactive=="NO"?"notactive":"active"); ?>">
              <ul class="infotable-ul">
                <li class="infotable-li number"><a href="<?php echo $lico['baseurl.ssl']; ?>/editmachine/<?php echo $id; ?>.html"><span><?php echo $id; ?></span></a>&nbsp;</li>
                <li class="infotable-li col04"><a href="<?php echo $lico['baseurl.ssl']; ?>/editmachine/<?php echo $id; ?>.html"><span><?php echo $name; ?></span></a>&nbsp;</li>
                <li class="infotable-li sysclass"><a href="<?php echo $lico['baseurl.ssl']; ?>/editmachine/<?php echo $id; ?>.html"><span><?php echo $sysclass; ?></span></a>&nbsp;</li>
                <li class="infotable-li cpu"><a href="<?php echo $lico['baseurl.ssl']; ?>/editmachine/<?php echo $id; ?>.html"><span><?php echo $cpu; ?></span></a>&nbsp;</li>
                <li class="infotable-li ctime"><a href="<?php echo $lico['baseurl.ssl']; ?>/editmachine/<?php echo $id; ?>.html"><span><?php echo $mtime; ?></span></a>&nbsp;</li>
                <li class="infotable-li delete"><img src="/gfx/delete.png" title="Delete this machine..." alt="Delete this machine..." style="cursor:pointer;" onclick="DeleteMachine(<?php echo $id; ?>);"/>&nbsp;</li>
              </ul>
            </div>
            <?php
          }
        }
        ?>
        </div>
        
    </div>
  </div>
</div>
